<?php
session_start();
if (!(isset($_SESSION['canSetBio']) && $_SESSION['canSetBio']=='true')) {
  die('此链接已经逾期作废');
}
require_once('fun.php');
ob_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改个人资料</title>
<style type="text/css"> 
<!--
body {
	background-color: #BBB577;
}
#main {
	background-color: #D8D3AF;
}
#main td {
	background-color: #E9E7D1;
	padding: 40px;
	font-size: 14px;
	color: #000000;
}
-->
</style>
</head>
 
<body>
<table id="main" width="100%" height="100%" border="0" cellpadding="0" cellspacing="80">
  <tr>
    <td>
	<p>赶快设置你的个人资料吧！</p>
	<form action="" method="post" name="" id=""><?php
if (isset($_POST["name"])) {
	$rtn = $connection->post('account/update_profile', array('name' => $_POST["name"], 'url' => $_POST["url"], 'location' => $_POST["location"], 'description' => $_POST["description"]));
	if ($rtn===NULL) {
		echo "<p>更新失败</p>";
		$_SESSION["me"] = array();
		$_SESSION["me"]["name"] = $_POST["name"];
		$_SESSION["me"]["url"] = $_POST["url"];
		$_SESSION["me"]["location"] = $_POST["location"];
		$_SESSION["me"]["description"] = $_POST["description"];
	} else {
		echo "<p>更新完成啦 :)</p>";
		$_SESSION["me"] = $rtn;
	}
} else 
	$_SESSION["me"] = $connection->get('account/verify_credentials', array());
?>
	  <label>名　字
	  <input name="name" type="text" id="name" value="<?php echo $_SESSION["me"]->name; ?>" maxlength="20">
	  </label><br>
	  <label>网　站
	  <input name="url" type="text" id="url" value="<?php echo $_SESSION["me"]->url; ?>" maxlength="100">
	  </label><br>
	  <label>所在地
	  <input name="location" type="text" id="location" value="<?php echo $_SESSION["me"]->location; ?>" maxlength="30">
	  </label><br>
	  <label>简　介
	  <input name="description" type="text" id="description" value="<?php echo $_SESSION["me"]->description; ?>" maxlength="160">
	  </label><br><br>
	  <input type="submit" name="Submit" value="修改">
	</form></td>
  </tr><?php /*
  <tr>
    <td>
	<p>或者……你还可以修改头像</p><?php
	if (isset($_FILES["thumb"]["tmp_name"])) {
		$rtn = $connection->post('account/update_profile_image', array('@image' => '@'.file_get_contents($_FILES["thumb"]["tmp_name"])));
		if ($rtn===NULL) {
			echo "<p>更新失败</p>";
		} else {
			echo "<p>更新完成啦 :)</p>";
			$_SESSION["me"] = $rtn;
		}
	}
?>
	<form action="" method="post" enctype="multipart/form-data" name="" id="">
	  <img src="<?php echo $_SESSION["me"]->profile_image_url; ?>" align="right" alt="当前使用的头像">
	  <label>文件
	  <input name="thumb" type="file" id="thumb">
	  <br>
	  </label>
	  ·支持小于700k的GIF、JPG或PNG。如果宽或者高大于500像素将被缩小！<br>
	  <br>
	  <input type="submit" name="Submit" value="上传">
	</form></td>
  </tr>*/ ?>
</table>
</body>
</html>